package com.yuwei.play.adapter

import android.graphics.Color
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.yuwei.database.entity.MovieEntityItem
import com.yuwei.play.R


class PlayListAdapter : BaseQuickAdapter<MovieEntityItem, BaseViewHolder>(R.layout.play_list_item) {
    private var position = -1
    fun sendPosition(index:Int){
        this.position = index
    }
    override fun convert(holder: BaseViewHolder, item: MovieEntityItem) {
        if (position == holder.adapterPosition){
            val iv = holder.getView<ImageView>(R.id.play_video_iv)
            Glide.with(context).load(item.videomainimag).transform(
                RoundedCorners(10)
            ).into(iv)
            holder.setText(R.id.player_video_title,item.name)
                .setTextColor(R.id.player_video_title,Color.RED)
            holder.setText(R.id.player_video_text,item.description)
                .setTextColor(R.id.player_video_text,Color.RED)
        }else{
            val iv = holder.getView<ImageView>(R.id.play_video_iv)
            Glide.with(context).load(item.videomainimag).transform(
                RoundedCorners(10)
            ).into(iv)
            holder.setText(R.id.player_video_title,item.name)
                .setTextColor(R.id.player_video_title,Color.BLACK)
            holder.setText(R.id.player_video_text,item.description)
                .setTextColor(R.id.player_video_text,Color.GRAY)
        }


    }
}